import pymysql


# 登录
def search(name, pwd):
    # 1 创建数据库连接
    con = pymysql.connect(
        host="localhost",
        user="root",
        passwd="20011231ZENG",
        database="pycharm",
        charset="utf8",
        port=3306
    )
    # 2 获取游标，操作数据库的对象
    cur = con.cursor()
    # 3 定义查询
    sql = "select * from userInfo where userName=%s and userPwd=%s"
    # 4 编译sql
    cur.execute(sql, (name, pwd))
    # 5 获取查询结果
    rs = cur.fetchall()
    print(rs)
    # 6 关闭链接
    cur.close()
    con.close()
    return rs
